<template>
  <div>
    <!-- 面包屑导航区 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>数据分析报表</el-breadcrumb-item>
      <el-breadcrumb-item>SFC装配信息追溯报表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <div class="sea-box">
        <el-form ref="form" label-width="120px">
          <el-form-item label="SFC">
            <el-input v-model="sfcList.sfc"></el-input>
          </el-form-item>
          <el-form-item label="操作">
            <el-input v-model="sfcList.operation"></el-input>
          </el-form-item>
        </el-form>
        <div class="btn">
          <el-button type="success" @click="search">查询</el-button>
          <el-button type="success" @click="empty">清空</el-button>
        </div>
      </div>
      <div v-show="materDV" class="seatable">
          <!-- 表格区域 -->
      <el-table
        stripe
        border
        ref="multipleTable"
        :data="materList"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          prop="item"
          label="物料编号"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="item_name"
          label="物料名称"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="item_desc"
          label="物料描述"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="item_type"
          label="物料类型"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="create_time"
          label="接收时间"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="by_user"
          label="操作员"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="item_sfc"
          label="物料sfc"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="batch"
          label="批次号"
          align="center"
        >
        </el-table-column>
      <!-- 分页区域 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageNow"
        :page-sizes="[1, 2, 5, 10]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="rowCount"
      >
      </el-pagination>
      </el-table>
      </div>
    </el-card>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      sfcList: {
        sfc: "",
        operation: "",
      },
      materList: [],
      pageCount: 1,
      pageNow: 1,
      pageSize: 10,
      rowCount: 0,
      materDV:false,
    };
  },
  methods: {
    empty() {
      (this.sfcList.sfc = ""), (this.sfcList.operation = "");
    },
    search() {
        this.materDV = true
      this.$axios({
        headers: {
          "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        },
        method: "post",
        url: "/IE_MES/report/sfc_assembly_info_listData.shtml?"+"sfc="+this.sfcList.sfc+"&operation="+this.sfcList.operation,
        data: this.$qs.stringify({
          pageSize: this.pageSize,
          pageNow: this.pageNow,
        }),
      }).then((res) => {
        console.log(res.data);
        this.materList = res.data.records;
        this.pageCount = res.data.pageCount;
        this.pageNow = res.data.pageNow;
        this.pageSize = res.data.pageSize;
        this.rowCount = res.data.rowCount;
      });
    },
    handleSizeChange(newSize) {
      this.pageSize = newSize;
      this.search();
    },
    handleCurrentChange(newPage) {
      this.pageNow = newPage;
      this.search();
    },
    formatDate(data) {
      var date = new Date(data);
      var YY = date.getFullYear() + "-";
      var MM =
        (date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1) + "-";
      var DD = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
      var hh =
        (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
      var mm =
        (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
        ":";
      var ss =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
      return YY + MM + DD + " " + hh + mm + ss;
    },
  },
};
</script>

<style lang="less" scoped>
.sea-box {
  width: 50%;
  height: 150px;
  margin: 0 auto;
  position: relative;
  .btn {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
}
.seatable{
margin-top: 30px;
}
</style>